package model

import "gorm.io/gorm"

type User struct {
	gorm.Model
	UserName  string `gorm:"type:varchar(30);commit:用户名"`
	Password  string `gorm:"type:varchar(32);commit:密码"`
	AvatarUrL string `gorm:"type:varchar(255);commit:头像Url"`
	Status    string `gorm:"type:varchar(10);commit:状态:1:正常,2:异常"`
}

func (u *User) Register(db *gorm.DB) error {
	err := db.Create(&u).Error
	return err
}
func (u *User) IsUser(db *gorm.DB, userName string) error {
	err := db.Where("user_name = ?", userName).First(&u).Error
	return err
}
